/*
 * @Author: _LJP 2634716776@qq.com
 * @Date: 2023-12-25 16:52:51
 * @LastEditors: _LJP 2634716776@qq.com
 * @LastEditTime: 2024-01-02 15:04:40
 * @FilePath: /my_-linux/Pro24/AVL/AVLTree/test.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

#include <iostream>
#include "AVLTree.hpp"

using namespace std;

void test1()
{
    AVLTree<int, int> avl1;
    avl1.Insert(make_pair(1, 1));
    avl1.Insert(make_pair(2, 1));
    avl1.Insert(make_pair(5, 1));
    avl1.Insert(make_pair(3, 1));
    avl1.Insert(make_pair(7, 1));
    avl1.Insert(make_pair(55, 1));
    avl1.Insert(make_pair(34, 1));
    avl1.Insert(make_pair(14, 1));
    avl1.Insert(make_pair(77, 1));
    avl1.Insert(make_pair(23, 1));
    avl1.Insert(make_pair(16, 1));

    avl1.InOrder();
}

void test2()
{
    AVLTree<int, int> avl1;
    int a[] = {16, 3, 7, 11, 9, 26, 18, 14, 15};

    for (auto e : a)
    {
        avl1.Insert({e, e});
    }

    avl1.InOrder();
}
void test3()
{
    AVLTree<int, int> avl1;

    int a[] = {4, 2, 6, 1, 3, 5, 15, 7, 16, 14};
    // int a[] = {4, 2, 6, 1, 3, 5, 15, 7, 16, 14, 12, 14, 54, 23, 21, 56, 57, 45, 32};
    // int a[] = {4, 2, 6, 1 /*  ,3,5,15,7,16,14,12,14,54,23,21,56,57,45,32*/};

    for (auto e : a)
    {
        avl1.Insert({e, e});
        // cout << e << "插入:" << avl1.IsBalance() << endl;
        avl1.IsBalance();
    }

    avl1.InOrder();
    avl1.IsBalance();
}

void test4()
{
    srand(time(0));
    const size_t N = 10000;
    AVLTree<int, int> avl1;
    for (size_t i = 0; i < N; ++i)
    {
        size_t x = rand();
        avl1.Insert(make_pair(x, x));
    }
}

int main()
{
    test1();

    cout << "--------------------" << endl;

    test2();

    cout << "--------------------" << endl;

    test3();
    test4();

    return 0;
}